Fixing Cannot call method 'call' of undefined