fix couple issues of scope