Need to revert xor logic to be correct