changed code to show shortest path