        refIdx += 1;
                        mergedSplitDone = true;
                    }

                    if (mergedSplitDone) {
                        break;
                    }

                    // If no match after merging all tokens,
                    // align current token directly
                    if (length == rawCopy.length) {
                        alignedRaw.push(rawCopy[rawIdx]);
                        rawIdx += 1;
                        refIdx += 1;
                    }
    