                 running_total.key    = segment_ids[ITEM];
                 running_total.value  = identity;
             }
-
-            running_total.value = reduction_op(running_total.value, values[ITEM]);
+            else
+            {
+                running_total.value = reduction_op(running_total.value, values[ITEM]);
+            }
         }
 /*
-
         // Barrier for smem reuse
         __syncthreads();
+
+        KeyValuePair pairs[2];
+        pairs[0] = first_partial;
+        pairs[1] = running_total;
 
         // Use prefix scan to reduce values by segment-id.  The segment-reductions end up in items flagged as segment-tails.
         KeyValuePair block_aggregate;


        // Load values
        Value values[ITEMS_PER_THREAD];

        if (USE_SMEM_VALUE_CACHE)
        {
            // Barrier for smem reuse

            #pragma unroll
            for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ++ITEM)
            {
                values[ITEM] = d_values[value_offsets[ITEM]];
            }
        }

