Added a check to make sure a train exists first before attempting to retrieve its position in the changeRoute method.