Begin code factorization