modifed lost particle condition
extracted dump_particle part of the code
header for extracted function