fixed threshold bug