actually made it use the tree structure