refucktored code