histogramming routine first preliminary version