Declare variavles in the loop body (#4269)