refactoring search routing