router refactor; legacy algorithm for comparison