protect indexOf calls with typeof string