Wrap with index !== -1 check

Reported[1]. In the mean time, we wrap the code with this condition.

[1]: https://twitter.com/terinjokes/status/381206072075100160