bugfix write_hist