cleaned up some variable scopes