Fixed a bug when loading as global function