fix a bug: sync global counting cross sub-script execution