Fixed a bug: global variable issue