complete the addHist function