Check response type before calling indexOf

resolves #1