refractoring of the code