An Adaptive Detection Algorithm