midpoint correction algo outlined