1) refactored code