implemented thresholded gap pruning