correcting for loop unassigned var