Refactoring before adding the histogram plot.