implementing initial search logic