body of route calculation loop