added xor logic