Refactoring search functions