improved auto adjustment akgorithm