improved dijkstra algorithm