added thresholding option when decoding