added thresholding option