Updated refractored code