refractored code.