a lot of improvements and half done dijkstra