refactored out some globals
refactored out some globals