Learning to stay on the Path