nit: `if (flag)`