fix the histogram merging script