tiny improvements on Dijkstra