rebinning function added