remove some bugs in the binning routine