fixed tree building