changed the search logic