Fixed bugs in the trajectory