Added rebin function