diff --git a/bot.py b/bot.py
index 4d4ed26..c1cc45e 100644
--- a/bot.py
+++ b/bot.py
@@ -147,7 +147,11 @@ class Bot:
             )
             if corners is not None and ids is not None:
                 for corner, i in zip(corners, ids):
-                    aruco_corners[i[0]] = corner
+                    index = i[0]
+                    if not (0 <= index < 4):
+                        warnings.warn(f"Invalid ArUco marker ID: {index}")
+                        continue
+                    aruco_corners[index] = corner
         assert annotated_image is not None
 
         del vcap