Refactor dijkstra app