refactor out tree