added backward_trajectory function