refactored code tree