updated with djikstras algoritm