Optimized adjust function.