Stop your formulas from breaking by switching from grid-based coordinates (ROW) to stable table measurements (ROWS).
LAMBDA defines the custom logic, and SCAN moves that logic through your data range.