added an alternative way of thresholding, such that it is two-sided