Optimize `indexOf` usage

Use a simple `for`-loop as it is faster than native function.

See [jsPerf](http://jsperf.com/thor-indexof-vs-for).