refactoring: some locals eliminated