 
         CopySortedToOriginal_XSPH_D<<<numBlocks1, numThreads1>>>(
             mR3CAST(vel_XSPH_Sorted_D), mR3CAST(fsiGeneralData->vel_XSPH_D),
-            U1CAST(markersProximityD->gridMarkerIndexD), 
-            U1CAST(fsiGeneralData->activityIdentifierD), numObjectsH->numAllMarkers);
+            U1CAST(markersProximityD->gridMarkerIndexD),
+            U1CAST(fsiGeneralData->activityIdentifierD),
+            U1CAST(markersProximityD->mapOriginalToSorted),
+            numObjectsH->numAllMarkers);
     }
 
     if (density_initialization % paramsH->densityReinit == 0)

                                            Real3* originalXSPH,
                                            uint* gridMarkerIndex,
                                            uint* activityIdentifierD,
                                            const size_t numAllMarkers) {
    uint id = blockIdx.x * blockDim.x + threadIdx.x;
    if (id >= numAllMarkers)
        return;

    uint index = gridMarkerIndex[id];

    // Check the activity of this particle
    uint activity = activityIdentifierD[index];
    if(activity == 0)
        return;

    originalXSPH[index] = sortedXSPH[id];
}

//--------------------------------------------------------------------------------------------------------------------------------

                                       Real3* originalDerivTauXyXzYz,
                                       uint* gridMarkerIndex,
                                       uint* activityIdentifierD,
                                       uint* mapOriginalToSorted,
                                       const size_t numAllMarkers) {
    uint id = blockIdx.x * blockDim.x + threadIdx.x;
    if (id >= numAllMarkers)
        return;

    // Check the activity of this particle
    uint activity = activityIdentifierD[id];
    if(activity == 0)
        return;

    uint index = mapOriginalToSorted[id];

    originalDerivVelRho[id] = sortedDerivVelRho[index];
    if(paramsD.elastic_SPH){
        originalDerivTauXxYyZz[id] = sortedDerivTauXxYyZz[index];
        originalDerivTauXyXzYz[id] = sortedDerivTauXyXzYz[index];
    }
    return;
}
