Added xor, fixed bug