full commit with thresholding actually implemented