adding shortest path logic using dijkstras alg