new code for doing different thresholds