improved function for datasets