changed path calc to Dijkstra algorithm