implemented refactor idea in c/histogram.cpp