using xor to reverse ordering