fixed bug with shortest path calculation