redid createVars code to use for loops