update RedistributeValuesAndBuckets in order to be more generic