tweaked tree building mechanism