Fix usage of global variable