Fix 'undefined' is not a function