fixing thresholding code when hard threshold applied