fixed thresholding issue