add thresholding