more logic work on shortest path algorithm