Fix threshold calculation.