factorized code.