fix ordering of thresholding