factorize the code