refcored code