Rafactored code