diff --git a/src/glpios06.c b/src/glpios06.c
index 53f8dcf..becb10a 100644
--- a/src/glpios06.c
+++ b/src/glpios06.c
@@ -1208,13 +1208,12 @@ static void add_cut(glp_tree *tree, struct MIR *mir)
       return;
 }
 
-static int aggregate_row(glp_tree *tree, struct MIR *mir)
+static int aggregate_row(glp_tree *tree, struct MIR *mir, IOSVEC *v)
 {     /* try to aggregate another row */
       glp_prob *mip = tree->mip;
       int m = mir->m;
       int n = mir->n;
       GLPAIJ *aij;
-      IOSVEC *v;
       int ii, j, jj, k, kk, kappa = 0, ret = 0;
       double d1, d2, d, d_max = 0.0;
       /* choose appropriate structural variable in the aggregated row
@@ -1272,13 +1271,17 @@ static int aggregate_row(glp_tree *tree, struct MIR *mir)
       xassert(!mir->isint[kappa]);
       /* find another row, which have not been used yet, to eliminate
          x[kappa] from the aggregated row */
-      for (ii = 1; ii <= m; ii++)
-      {  if (mir->skip[ii]) continue;
-         for (aij = mip->row[ii]->ptr; aij != NULL; aij = aij->r_next)
-            if (aij->col->j == kappa - m) break;
-         if (aij != NULL && fabs(aij->val) >= 0.001) break;
+      ii = 0;
+      for (aij = mip->col[kappa - m]->ptr; aij != NULL;
+         aij = aij->c_next)
+      {  if (aij->row->i > m) continue;
+         if (mir->skip[aij->row->i]) continue;
+         if (fabs(aij->val) >= 0.001)
+         {  ii = aij->row->i;
+            break;
+         }
       }
-      if (ii > m)
+      if (ii == 0)
       {  /* nothing found */
          ret = 2;
          goto done;
@@ -1289,7 +1292,7 @@ static int aggregate_row(glp_tree *tree, struct MIR *mir)
       mir->agg_row[mir->agg_cnt] = ii;
       mir->skip[ii] = 2;
       /* v := new row */
-      v = ios_create_vec(m+n);
+      ios_clear_vec(v);
       ios_set_vj(v, ii, 1.0);
       for (aij = mip->row[ii]->ptr; aij != NULL; aij = aij->r_next)
          ios_set_vj(v, m + aij->col->j, - aij->val);
@@ -1303,7 +1306,6 @@ static int aggregate_row(glp_tree *tree, struct MIR *mir)
       xassert(jj != 0);
       ios_linear_comb(mir->agg_vec,
          - mir->agg_vec->val[j] / v->val[jj], v);
-      ios_delete_vec(v);
       ios_set_vj(mir->agg_vec, kappa, 0.0);
 #if _MIR_DEBUG
       ios_check_vec(mir->agg_vec);
@@ -1319,6 +1321,7 @@ void ios_mir_gen(glp_tree *tree, void *gen)
       int n = mir->n;
       int i;
       double r_best;
+      IOSVEC *work;
       xassert(mip->m >= m);
       xassert(mip->n == n);
       /* obtain current point */
@@ -1329,6 +1332,7 @@ void ios_mir_gen(glp_tree *tree, void *gen)
 #endif
       /* reset bound substitution flags */
       memset(&mir->subst[1], '?', m+n);
+      work = ios_create_vec(m+n);
       /* try to generate a set of violated MIR cuts */
       for (i = 1; i <= m; i++)
       {  if (mir->skip[i]) continue;
@@ -1396,7 +1400,7 @@ loop:    ;
          {  /* failure */
             if (mir->agg_cnt < MAXAGGR)
             {  /* try to aggregate another row */
-               if (aggregate_row(tree, mir) == 0) goto loop;
+               if (aggregate_row(tree, mir, work) == 0) goto loop;
             }
          }
          /* unmark rows used in the aggregated constraint */
@@ -1409,6 +1413,7 @@ loop:    ;
             }
          }
       }
+      ios_delete_vec(work);
       return;
 }
 
