Updated/new version of Dijkstra's algorithm