fixed bug of var out of scope.