fix inner loop var