Optimizing function cfeps. Function sort_by_buckets in progress