fixes to for loop