fix threshold variable declaration bug