fix threshold bug