move more code into the Trajectory class