added thresholding
implemented copy for patch