fix bugs.
refactor the scope.