diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp
index 380edee825..51f4be98e2 100644
--- a/src/ipa/libipa/exposure_mode_helper.cpp
+++ b/src/ipa/libipa/exposure_mode_helper.cpp
@@ -240,13 +240,11 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const
 			 exposure / (exposureTime * gain * quantGain) };
 	}
 
-	double stageGain = clampGain(1.0);
-	double lastStageGain = stageGain;
+	double lastStageGain = clampGain(1.0);
 
 	for (const auto &stage : stages_) {
 		utils::Duration stageExposureTime = clampExposureTime(stage.exposureTime,
 								      &quantGain);
-		stageGain = clampGain(stage.gain);
 
 		/*
 		 * We perform the clamping on both exposure time and gain in
@@ -267,6 +265,8 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const
 		}
 
 		/* Clamp the exposureTime to stageExposureTime and regulate gain. */
+		const double stageGain = clampGain(stage.gain);
+
 		if (stageExposureTime * stageGain >= exposure) {
 			exposureTime = stageExposureTime;
 			gain = clampGain(exposure / exposureTime, &quantGain2);
@@ -283,10 +283,10 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const
 	 * From here on all we can do is max out the exposure time, followed by
 	 * the analogue gain. If we still haven't achieved the target we send
 	 * the rest of the exposure time to digital gain. If we were given no
-	 * stages to use then the default stageGain of 1.0 is used so that
-	 * exposure time is maxed before gain is touched at all.
+	 * stages to use then the default gain of 1.0 is used so that exposure
+	 * time is maxed before gain is touched at all.
 	 */
-	exposureTime = clampExposureTime(exposure / stageGain, &quantGain);
+	exposureTime = clampExposureTime(exposure / lastStageGain, &quantGain);
 	gain = clampGain(exposure / exposureTime, &quantGain2);
 	quantGain *= quantGain2;
 
