adaptive algorithm