finished the search function