now dynamically creates the tree