"end for" bug