Small fix in shortestPath method