Fixed a bug concerning external global variable