Improved precalculation of the thresholds