First attempt at djikstras algorithm