Fix checking of indexOf return value