Fixed the issue with global variable