fixing xor for adjacent ranges