Refactoring search method