revised analysis function to include histogram data.