Add protection against empty histograms