diff --git a/src/dictionaries/morphosyntactic/ner_file.py b/src/dictionaries/morphosyntactic/ner_file.py
index 8fe2a78ce94b78f5343f28bd4e410ade3f2ff4e7..f31dde7dbb9aa19fee024c49b9d4994c9fbcd98d 100644
--- a/src/dictionaries/morphosyntactic/ner_file.py
+++ b/src/dictionaries/morphosyntactic/ner_file.py
@@ -93,7 +93,8 @@ class NERFileMorphosyntacticDictionary(MorphosyntacticDictionary):
             if original_entry_type_name in self._dictionary:
                 entry_type = original_entry_type_name
 
-                if morpho_tag in self._dictionary[entry_type]:
+                if morpho_tag in self._dictionary[entry_type] \
+                        and morpho_tag in self._dictionary[entry_type]:
                     lemma = random.choice(
                         list(self._dictionary[entry_type][morpho_tag].keys())
                     )
diff --git a/src/replacers/ner_replacer.py b/src/replacers/ner_replacer.py
index fb212b3ef60ff6c9a5ba917ad0cee2a5ba144d3b..b2d5564469c4613be4211ba40af69a866a15be1a 100644
--- a/src/replacers/ner_replacer.py
+++ b/src/replacers/ner_replacer.py
@@ -61,7 +61,7 @@ class NERReplacer(ReplacerInterface):
                 )
                 morpho_detections[key].append(detection)
             else:
-                key = (text[start:end], detection.TYPE_NAME)
+                key = (text[start:end], detection_entry.TYPE_NAME)
                 non_morpho_detections[key].append(detection)
 
         # Replace morphosyntactic detections