nit: declare `i` locally