started fixing buildtree method.