some code factorisation