Rearange order of ORs and ANDS