refactor tree