Factor xor out into module