fix problem with global variable