Refactoring scoped vars