refactored tree component