refactoring search feature