move var dec. and var assignment back into main loop
removed inserting new lines into code to better preserve line numbers