new binning algorithm