Slightly changed threshold formula.