simplified the histogram function by including a call to the summary table. This will reduce the running time considerably