Fixed issue with global variables