use particles.nparticles instead of len()