Added a thresholding algorithm to parallelize