move conditional queries to scopes