Fixes scoping error
Merge pull request #17 from nifengle/final-refactor

Fixes scoping error