diff --git a/projects/common/util/unit-definition-sanitizer.ts b/projects/common/util/unit-definition-sanitizer.ts
index 19f9e0a36836b070b8ae74ffba7aa10cd7bb94ce..d3f4baea262b3e46eb4d386404d4c496c98ccf3d 100644
--- a/projects/common/util/unit-definition-sanitizer.ts
+++ b/projects/common/util/unit-definition-sanitizer.ts
@@ -94,7 +94,7 @@ export class UnitDefinitionSanitizer {
    */
   private static handleClozeElements(elementList: UIElement[]): void {
     const clozeElements = elementList.filter(element => element.type === 'cloze');
-    if (clozeElements[0].text) {
+    if (clozeElements.length && clozeElements[0].text) {
       clozeElements.forEach((element: Record<string, any>) => {
         const replacedText = element.text.replace(/\\i|\\z|\\r/g, (match: string) => {
           switch (match) {