Replace conversion to xor
Fixed bug with xor