rearrange logical ops to group them together more consistently.