fix buckets logic