added code for dijkstra