Another example refactored with closure + nonlocals()