Moved the for loop initial declarations for variables into a global state