Fixed the buggy pathfinding