Factorize code.