indexOf and lastIndexOf simplifications