use local var in loop