Added corner cases for Djikstra