                     ctx.cigar.is_insertion[idx.read_start + current_bp_idx + batch.cigars[event].len - 1] = 1;
                 }
 
-                num_errors++;
+                // if we are inside the clipped read window, count this error
+                // xxxnsubtil: unclear what happens if only part of the insertion is inside the clipped read window --- can this happen?
+                if (current_bp_idx >= read_window_clipped.x && current_bp_idx <= read_window_clipped.y)
+                    num_errors++;
+
                 break;
 
             case cigar_event::D:

        const uint32 align_offset = batch.alignment_start[read_index];
        const uint32 reference_alignment_start = seq_base + align_offset;

        uint16 current_bp_idx = 0;
        uint16 num_errors = 0;


                    ctx.cigar.is_deletion[idx.read_start + current_bp_idx] = 1;
                }

                // if we are inside the clipped read window, count this error
                if (current_bp_idx >= read_window_clipped.x && current_bp_idx <= read_window_clipped.y)
                    num_errors++;

                break;
            }
        }
