Text this: An iterative method for curve adjustment based on optimization of a variable and its application