Refactoring maximizing xor