fixing nearestPath