Moves some logic to a search method.