Improved the mesh to particle function