updated Dijkstra to account for backtracking