added optimized xor