correct loop indices and use time from trajectory for timeout