scan bodged together, works for histograms with minimum of 1024 bins