corrected error in the thresholding