XOR encoding slightly rewritten