Function for comparison of trajectories added