simplify dijkstra implementation