changed named scopes to be compatible with mysql and pg