binning function finished