[Thresholding] reduced code duplication