clean up the generate hierarchical data code