adaptive thresholding based on distance added