Move search where clause in model