modified ruleOne to also apply optimization to subquery