Fixed a bug when global variables wasn't as global as expected