working on the pathfinder algorithm