diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index 5ce1258b02f18090b936ed693e51314258ce8a9d..4233d3bd34c0bd19754c94769db20e0b7d12d7e4 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -2022,14 +2022,20 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
   {
     READ_FLAG(uiCode, "sps_gpm_enabled_flag");
     pcSPS->setUseGeo(uiCode != 0);
-    if (pcSPS->getUseGeo() && pcSPS->getMaxNumMergeCand() >= 3)
+    if (pcSPS->getUseGeo())
     {
-      READ_UVLC(uiCode, "max_num_merge_cand_minus_max_num_gpm_cand");
-      CHECK(pcSPS->getMaxNumMergeCand() < uiCode, "Incorrrect max number of GEO candidates!");
-      pcSPS->setMaxNumGeoCand((uint32_t)(pcSPS->getMaxNumMergeCand() - uiCode));
+      if (pcSPS->getMaxNumMergeCand() >= 3)
+      {
+        READ_UVLC(uiCode, "max_num_merge_cand_minus_max_num_gpm_cand");
+        CHECK(pcSPS->getMaxNumMergeCand() - 2 < uiCode,
+              "max_num_merge_cand_minus_max_num_gpm_cand must not be greater than the number of merge candidates minus 2");
+        pcSPS->setMaxNumGeoCand((uint32_t)(pcSPS->getMaxNumMergeCand() - uiCode));
+      }
+      else
+      {
+        pcSPS->setMaxNumGeoCand(2);
+      }
     }
-    else if (pcSPS->getUseGeo())
-      pcSPS->setMaxNumGeoCand(2);
   }
   else
   {
diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp
index 295bde3ac02eda8c6b21dba698e59cea47f0d138..7a65d27e7e6cc6204fc88440f3753f0171cbfb60 100644
--- a/source/Lib/EncoderLib/VLCWriter.cpp
+++ b/source/Lib/EncoderLib/VLCWriter.cpp
@@ -1201,10 +1201,17 @@ void HLSWriter::codeSPS( const SPS* pcSPS )
   if (pcSPS->getMaxNumMergeCand() >= 2)
   {
     WRITE_FLAG(pcSPS->getUseGeo() ? 1 : 0, "sps_gpm_enabled_flag");
-    if (pcSPS->getUseGeo() && pcSPS->getMaxNumMergeCand() >= 3)
+    if (pcSPS->getUseGeo())
     {
-      CHECK(pcSPS->getMaxNumMergeCand() < pcSPS->getMaxNumGeoCand(), "Incorrrect max number of GEO candidates!");
-      WRITE_UVLC(pcSPS->getMaxNumMergeCand() - pcSPS->getMaxNumGeoCand(), "max_num_merge_cand_minus_max_num_gpm_cand");
+      CHECK(pcSPS->getMaxNumMergeCand() < pcSPS->getMaxNumGeoCand(),
+            "The number of GPM candidates must not be greater than the number of merge candidates");
+      CHECK(2 > pcSPS->getMaxNumGeoCand(),
+            "The number of GPM candidates must not be smaller than 2");
+      if (pcSPS->getMaxNumMergeCand() >= 3)
+      {
+        WRITE_UVLC(pcSPS->getMaxNumMergeCand() - pcSPS->getMaxNumGeoCand(),
+                   "max_num_merge_cand_minus_max_num_gpm_cand");
+      }
     }
   }