finish implementing treebuilder