refractored code