Fix minor bug when calling shortestPath