fixing bad loop var