made binning more flexible