 
         uint2 vcf_db_range = ctx.snp_filter.active_vcf_ranges[read_index];
 
+        const uint32 cigar_start = ctx.cigar.cigar_offsets[idx.cigar_start];
+        const uint32 cigar_end = ctx.cigar.cigar_offsets[idx.cigar_start + idx.cigar_len];
+
         // traverse the VCF range and mark corresponding read BPs as inactive
         for(uint32 feature = vcf_db_range.x; feature <= vcf_db_range.y; feature++)
         {
-            const uint32 cigar_start = ctx.cigar.cigar_offsets[idx.cigar_start];
-            const uint32 cigar_end = ctx.cigar.cigar_offsets[idx.cigar_start + idx.cigar_len];
-
             // compute the feature range as offset from alignment start
             const int feature_start = db.reference_window_start[feature] - ref_sequence_offset;
             const int feature_end = db.reference_window_start[feature] + db.alignment_window_len[feature] - ref_sequence_offset;

            vcf_range.x--;
        }

        // check for overlap at the edges of the range
        if (db.reference_window_start[vcf_range.x] < alignment_window.x &&
                db.reference_window_start[vcf_range.y] + db.alignment_window_len[vcf_range.y] > alignment_window.y)
        {
            // emit an empty VCF range
            ctx.snp_filter.active_vcf_ranges[read_index] = make_uint2(uint32(-1), uint32(-1));
        } else {
            ctx.snp_filter.active_vcf_ranges[read_index] = vcf_range;
        }
    }

    // finally apply the VCF filter
    // this will create zeros in the active location list for each BP that matches a known variant
    parallel<system>::for_each(snp.active_read_ids.begin(),
                               snp.active_read_ids.end(),
                               filter_bps<system>(context, batch.device));
}
INSTANTIATE(filter_known_snps);

