added a try and except statement for get_index -> get_particle_index