updated histogram function