refactor maximizing-xor