use threshold variable