implment the search function