fix for loop scope