Thank you for the feedback I'll look for it. It doesn't seem intended that the guard walks in a random direction. He's supposed to restart the path by going in the opposite direction.
I tried it again, looks like Im just dumb and forgot that the starting position counts as a part of the path too! Your code is fine, sorry, my mistake haha.