diff --git a/predtuner/pipedbin.py b/predtuner/pipedbin.py
index 4cdfe715b8352e62ce2a6174a11688cd5f44a968..17ae27044689f2a25076f4c5b8399989864a29ed 100644
--- a/predtuner/pipedbin.py
+++ b/predtuner/pipedbin.py
@@ -339,7 +339,7 @@ class HPVMConfigBuilder:
         merged_to_original = []
         while lhs < len(types):
             widx = 0
-            while widx < len(mm) and types[rhs] in mm[widx]:
+            while widx < len(mm) and rhs < len(types) and types[rhs] in mm[widx]:
                 rhs += 1
                 widx = rhs - lhs
             if rhs == lhs: