added xor and applyXor