fixed missing 'global' keyword bug