         }
     }
 
-    CUDA_HOST_DEVICE int getReadCoordinateForReferenceCoordinate(const uint32 read_index, uint32 ref_coord)
+    enum AdaptorTail
+    {
+        left,
+        right,
+    };
+
+    CUDA_HOST_DEVICE int getReadCoordinateForReferenceCoordinate(const uint32 read_index, uint32 ref_coord, AdaptorTail tail)
     {
         const CRQ_index idx = batch.crq_index(read_index);
 

                if (read_coord == uint16(-1))
                {
                    // if there is no read coordinate, we must be in a deletion
                    // this can (in theory) only happen for the right tail
                    // move forward until we find a valid clipping point
                    while(ev < cigar_stop)
                    {
                        read_coord = ctx.cigar.cigar_event_read_coordinates[ev];

                        if (read_coord != uint16(-1))
                            break;

                        ev++;
                    }

                    // if we get here, then we failed to find a clipping coordinate
                    // this should not happen unless the read is malformed
                    if (ev == cigar_stop)
                        return -1;
                }


        if (refStart < 0)
        {
            start = 0;
            stop = getReadCoordinateForReferenceCoordinate(read_index, uint32(refStop), AdaptorTail::left);
        } else {
            start = getReadCoordinateForReferenceCoordinate(read_index, uint32(refStart), AdaptorTail::right);
            stop = ctx.cigar.read_window_clipped[read_index].y - ctx.cigar.read_window_clipped[read_index].x - 1;
        }

