# Question on condition for AdjustLevelsAndDepthInPlace function

**URL:** <https://openfhe.discourse.group/t/question-on-condition-for-adjustlevelsanddepthinplace-function/2249>\
**Category:** Library Questions\
**Created:** [January 2, 2026, 1:24pm UTC](https://openfhe.discourse.group/t/question-on-condition-for-adjustlevelsanddepthinplace-function/2249 "2026-01-02T13:24:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yhh](https://avatars.discourse-cdn.com/v4/letter/y/c57346/32.png) [@yhh](https://openfhe.discourse.group/u/yhh)\
**Post date:** [January 2, 2026, 1:24pm UTC](https://openfhe.discourse.group/t/question-on-condition-for-adjustlevelsanddepthinplace-function/2249/1 "2026-01-02T13:24:32Z")

</div>

Hi,  
I am curious why the if-else branch(probably Line645-647) i touched following from src/pke/lib/scheme/ckksrns/ckksrns-leveledshe.cpp still need to add compositeDegree in the condition check after we did the modreduce option?

```auto
    if (c1lvl < c2lvl) {
        if (c1depth == 2) {
            if (c2depth == 2) {
                double scf1 = ciphertext1->GetScalingFactor();
                double scf2 = ciphertext2->GetScalingFactor();
                double scf = cryptoParams->GetScalingFactorReal(c1lvl);
                double q1 = cryptoParams->GetModReduceFactor(sizeQl1 - 1);
                for (uint32_t j = 1; j < compositeDegree; j++) {
                    q1 *= cryptoParams->GetModReduceFactor(sizeQl1 - j - 1);
                }
                EvalMultCoreInPlace(ciphertext1, scf2 / scf1 * q1 / scf);
                ModReduceInternalInPlace(ciphertext1, compositeDegree);
                if (c1lvl + compositeDegree < c2lvl) {
                    LevelReduceInternalInPlace(ciphertext1, c2lvl - c1lvl - compositeDegree);
                }
                ciphertext1->SetScalingFactor(ciphertext2->GetScalingFactor());
}
...
}}

```

Great thanks for your help.

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [January 5, 2026, 7:11pm UTC](https://openfhe.discourse.group/t/question-on-condition-for-adjustlevelsanddepthinplace-function/2249/2 "2026-01-05T19:11:31Z")

</div>

After a more expensive ModReduce was done for ciphertext1, additional RNS limbs in ciphertext1 (as compared to ciphertext2) can be removed by using a cheap LevelReduce method.
