Corrected iteration of variables