Adjusted line following code with comments