refactored to no longer set scope variables in scope functions