Revert "Revert "fixed Dijkstra's""

This reverts commit cf6129bcf2352a9e6746be5df0d09d264200ee76.