Implement the search function