Adding code for shortestPath