change flatten_datasets to get_headings