using while loop for regression histograms