optimize logical xor