diff --git a/include/otbTensorflowMultisourceModelFilter.hxx b/include/otbTensorflowMultisourceModelFilter.hxx
index eb47fb42206f7c17c513cdb45d3b722577e9983e..c09850bfe8dd71c6b4bfc25abbad4b9e3acdec86 100644
--- a/include/otbTensorflowMultisourceModelFilter.hxx
+++ b/include/otbTensorflowMultisourceModelFilter.hxx
@@ -337,8 +337,8 @@ TensorflowMultisourceModelFilter<TInputImage, TOutputImage>
     SizeType toPad(this->GetInputReceptiveFields().at(i));
     for(unsigned int dim = 0; dim<ImageType::ImageDimension; ++dim)
       {
-      int valToPad = 1 + (this->GetOutputExpressionFields().at(0)[dim] - 1) * m_OutputSpacingScale * this->GetInput(i)->GetSpacing()[dim] / this->GetInput(0)->GetSpacing()[dim];
-      if (valToPad>toPad[dim])
+      int valToPad = 1 + (this->GetOutputExpressionFields().at(0)[dim] - 1) * m_OutputSpacingScale * this->GetInput(0)->GetSpacing()[dim] / this->GetInput(i)->GetSpacing()[dim] ;
+      if (valToPad > toPad[dim])
         itkExceptionMacro("The input requested region of image #" << i << " is not consistent. Please check RF, EF, SF vs physical spacing.");
       toPad[dim] -= valToPad;
       }