bug fix histmaking script