refactored loop search
removed loop code from shortest path finder
further refactoring