 
         if (data_mask & AlignmentDataMask::CHROMOSOME)
         {
-            std::string sequence_name = get_sequence_name(data->core.tid);
+            uint32 tid = data->core.tid;
+            std::string sequence_name = get_sequence_name(tid);
             const bool seq_valid = reference->make_sequence_available(sequence_name);
 
             if (seq_valid)


        if (data_mask & AlignmentDataMask::MATE_CHROMOSOME)
        {
            std::string sequence_name = get_sequence_name(data->core.mtid);
            const bool seq_valid = reference->make_sequence_available(sequence_name);


                batch->chromosome.push_back(seq_id);
                batch->chromosome_map.mark_resident(seq_id);
            } else {
                if (tid != uint32(-1))
                {
                    // if a valid sequence was noted in the file but we couldn't load it, error out
                    fprintf(stderr, "ERROR: sequence %s not found in reference file\n", sequence_name.c_str());
                    exit(1);
                } else {
                    // if the read has no sequence, load it and let the filtering stage cull it
                    batch->chromosome.push_back(uint16(-1));
                }
            }
        }

