encapsulate search logic in the model and take it out of the controller