fix: variables declared outside loop