Added adaptive thresholding (alpha)