Histogram refactoring