fixes the bug that undefined is not a function;