fixing buildTree