fixed bug in enumerating loop variables