added new version which has different thresholds for each bin