small loop structure change, variable out of scope