move search from controller to model