How trains stay on tracks around curves