change implementation of binning