refactored where clauses