getDataset function that does the heavy work