Cannot read property 'indexOf' of null