Calculating the min and max of a dataset