search refactored