I improved the while loop of hist_plotting