TypeError: Cannot call method 'indexOf' of undefined