fix the search function