fixed bug that made dijkstra crash if no distance grid is passed