Reworked Dijkstra