Code to move between waypoints on the rail