Bug fix for global variable usage