minor improvement of findShortestPath method