Fixing bug in Pathfinder logic