removed unused threshold variable