Added code to construct histograms and tables