diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp
index 325208eef45012205fd7f342782844c3aab6fdd8..7e89a06a4fe6a0e7d63dce3f5cd4e1bca2b29ddd 100644
--- a/source/Lib/CommonLib/Slice.cpp
+++ b/source/Lib/CommonLib/Slice.cpp
@@ -2316,13 +2316,9 @@ SPS::SPS()
 , m_numExtraSHBitsBytes       ( 0 )
 #endif
 , m_numLongTermRefPicSPS      (  0)
+
 , m_log2MaxTbSize             (  6)
-#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE
-, m_maxNumMergeCand(MRG_MAX_NUM_CANDS)
-, m_maxNumAffineMergeCand(AFFINE_MRG_MAX_NUM_CANDS)
-, m_maxNumIBCMergeCand(IBC_MRG_MAX_NUM_CANDS)
-, m_maxNumGeoCand(0)
-#endif
+
 , m_useWeightPred             (false)
 , m_useWeightedBiPred         (false)
 , m_saoEnabledFlag            (false)
@@ -2374,7 +2370,12 @@ SPS::SPS()
 , m_GDREnabledFlag            ( true )
 , m_SubLayerCbpParametersPresentFlag ( true )
 , m_rprEnabledFlag            ( false )
-
+#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE
+, m_maxNumMergeCand(MRG_MAX_NUM_CANDS)
+, m_maxNumAffineMergeCand(AFFINE_MRG_MAX_NUM_CANDS)
+, m_maxNumIBCMergeCand(IBC_MRG_MAX_NUM_CANDS)
+, m_maxNumGeoCand(0)
+#endif
 {
   for(int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
   {
diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h
index 53528f726141f3eec22ca944211e8dc409ce1a2d..3d445f87f65f8c9545dccc457896035e1dbb4f12 100644
--- a/source/Lib/CommonLib/Slice.h
+++ b/source/Lib/CommonLib/Slice.h
@@ -1314,12 +1314,7 @@ private:
   RPLList           m_RPLList1;
   uint32_t          m_numRPL0;
   uint32_t          m_numRPL1;
-#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE
-  uint32_t          m_maxNumMergeCand;
-  uint32_t          m_maxNumAffineMergeCand;
-  uint32_t          m_maxNumIBCMergeCand;
-  uint32_t          m_maxNumGeoCand;
-#endif
+
   bool              m_rpl1CopyFromRpl0Flag;
   bool              m_rpl1IdxPresentFlag;
   bool              m_allRplEntriesHasSameSignFlag;
@@ -1459,7 +1454,12 @@ private:
   bool              m_ppsValidFlag[64];
   Size              m_scalingWindowSizeInPPS[64];
 #endif
-
+#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE
+  uint32_t          m_maxNumMergeCand;
+  uint32_t          m_maxNumAffineMergeCand;
+  uint32_t          m_maxNumIBCMergeCand;
+  uint32_t          m_maxNumGeoCand;
+#endif
 public:
 
   SPS();
diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp
index 4f77cf230e5556e5b15f7b0304731dc79ff02753..a65a48245728282911edfafdbd5c53db6a6dbcbb 100644
--- a/source/Lib/CommonLib/UnitTools.cpp
+++ b/source/Lib/CommonLib/UnitTools.cpp
@@ -748,10 +748,10 @@ bool PU::addMergeHMVPCand(const CodingStructure &cs, MergeCtx& mrgCtx, const int
 void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const int& mrgCandIdx)
 {
   const CodingStructure &cs = *pu.cs;
-  const Slice &slice = *pu.cs->slice;
 #if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE
   const uint32_t maxNumMergeCand = pu.cs->sps->getMaxNumIBCMergeCand();
 #else
+  const Slice &slice = *pu.cs->slice;
   const uint32_t maxNumMergeCand = slice.getPicHeader()->getMaxNumIBCMergeCand();
 #endif
   for (uint32_t ui = 0; ui < maxNumMergeCand; ++ui)
@@ -3448,10 +3448,11 @@ void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx )
 {
   MergeCtx tmpMergeCtx;
 
-  const Slice &slice = *pu.cs->slice;
+
 #if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE
   const uint32_t maxNumMergeCand = pu.cs->sps->getMaxNumMergeCand();
 #else
+  const Slice &slice = *pu.cs->slice;
   const uint32_t maxNumMergeCand = slice.getPicHeader()->getMaxNumMergeCand();
 #endif
   geoMrgCtx.numValidMergeCand = 0;