search refactoring