fix bug in forloop