Fixed clearing of global variable