If you check this condition first, then in the else you should be guaranteed to have to export the globals so you wouldn't need to duplicate that code.