fix variable scoping issues
Merge pull request #20 from jlambert121/var_scope_update

fix variable scoping issues