fix a bug in setThreshold