Using closures instead of global variables.