correct cases of NaN at the end of traj