Enclose everything in a closure to preserve global state