Added thresholding option