refactor pathfinder