diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py
index 54626bb38cd6471b8c63d03c2cb80c1462307211..d3e980976a5ccf4ec021daefc6df2b971ca22b6d 100644
--- a/src/Model/Geometry/ProfileXYZ.py
+++ b/src/Model/Geometry/ProfileXYZ.py
@@ -565,18 +565,18 @@ class ProfileXYZ(Profile, SQLSubModel):
                 start.append(y)
 
         end = []
+        if points[-1].z <= z:
+            end.append(station[-1])
+
         for i in reversed(range(self.number_points-1)):
-            if zz[i-1] <= z and zz[i] > z:
+            if zz[i] <= z and zz[i+1] > z:
                 y = np.interp(
                     z,
-                    [zz[i-1], zz[i]],
-                    [station[i-1], station[i]]
+                    [zz[i], zz[i+1]],
+                    [station[i], station[i+1]]
                 )
                 end.append(y)
 
-        if points[-1].z <= z:
-            end.append(station[-1])
-
         if len(start) != len(end):
             logger.error(f"ERROR in get_all_water_limits_ac")
             return [], []