refatored code