slight fix to for loop