refractoring code 1