implemented the search function