Turn list_datasets into a more generic method