clean up variable scoping