#2077 Fixed var statement in loop