Implemented the pathfinder