diff --git a/src/runner_doiact_vec.c b/src/runner_doiact_vec.c
index 00fc44ae5972a8ef9953acbc60d5d4164be5479d..f3d9ed2ec407adffdea63f7064d17c8a7d8d1702 100644
--- a/src/runner_doiact_vec.c
+++ b/src/runner_doiact_vec.c
@@ -1474,6 +1474,9 @@ void runner_dopair2_force_vec(struct runner *r, struct cell *ci,
                                     hi_max, hj_max, di_max, dj_min, max_index_i,
                                     max_index_j, &first_pi, &last_pj, e);
 
+  first_pi = 0;
+  last_pj = count_j - 1;
+
   /* Limits of the outer loops. */
   int first_pi_loop = first_pi;
   int last_pj_loop = last_pj;
@@ -1482,6 +1485,9 @@ void runner_dopair2_force_vec(struct runner *r, struct cell *ci,
    * to read into the cache. */
   last_pj = max(last_pj, max_index_i[count_i - 1]);
   first_pi = min(first_pi, max_index_j[0]);
+  
+  first_pi = 0;
+  last_pj = count_j - 1;
 
   /* Read the needed particles into the two caches. */
   int first_pi_align = first_pi;
@@ -1490,6 +1496,9 @@ void runner_dopair2_force_vec(struct runner *r, struct cell *ci,
                                             sort_j, shift, &first_pi_align,
                                             &last_pj_align, 1);
 
+  for(int i=0; i<count_i; i++) max_index_i[i] = last_pj;
+  for(int i=0; i<count_j; i++) max_index_j[i] = first_pi;
+
   /* Get the number of particles read into the ci cache. */
   int ci_cache_count = count_i - first_pi_align;