move the search logic into its own class