factorize, move domain codes into domains