fix global var (j) bug

fix the issue where j var become global bcs of var declaration absence