fix wrong indexOf condition