Fix indexOf check to allow for an index of 0