cleanup: code factorization