Refatored code