Fix bug with pathfinding