Fix error with slope thresholding