Now properly computes histograms