correct the usage of global variables