Moving search functionality to model