improved d5 dijkstra_pq (closer to the script)