speeds up thresholding