Optimize `indexOf` usage

Use a simple `for`-loop as it is faster than native function.