- refactored and scoped a bit