Improved Xor fuction