made the search functionality generic