changed ShortestPath script