Fixed the threshold bug