correcting improperly terminated statements as well as variable scoping issues in for loops