Eliminate the while loop

Replace the while loop evaluation of the line with a calculated one.