moves scope initialization to earlier point in script