Added a threshold variable.