improved bucketing for histogram