correction of pathfinding, no more infinite loop if there is no path