diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h
index 6a9a8e158..8faba43aa 100644
--- a/source/core/gamefuncs.h
+++ b/source/core/gamefuncs.h
@@ -160,3 +160,12 @@ inline int32_t getangle(walltype* wal)
         wall[wal->point2].y - wal->y);
 }
 
+inline TArrayView<walltype> wallsofsector(sectortype* sec)
+{
+    return TArrayView<walltype>(sec->firstWall(), sec->wallnum);
+}
+
+inline TArrayView<walltype> wallsofsector(int sec)
+{
+    return wallsofsector(&sector[sec]);
+}
diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp
index 1ff6b6e33..4c16cb94c 100644
--- a/source/games/duke/src/actors.cpp
+++ b/source/games/duke/src/actors.cpp
@@ -331,16 +331,17 @@ void movecyclers(void)
 		c->lotag += sect->extra;
 		if (c->state)
 		{
-			auto wal = sect->firstWall();
-			for (int x = sect->wallnum; x > 0; x--, wal++)
-				if (wal->hitag != 1)
+			for (auto& wal : wallsofsector(sect))
+			{
+				if (wal.hitag != 1)
 				{
-					wal->shade = j;
+					wal.shade = j;
 
-					if ((wal->cstat & CSTAT_WALL_BOTTOM_SWAP) && wal->nextwall >= 0)
-						wal->nextWall()->shade = j;
+					if ((wal.cstat & CSTAT_WALL_BOTTOM_SWAP) && wal.nextwall >= 0)
+						wal.nextWall()->shade = j;
 
 				}
+			}
 			sect->floorshade = sect->ceilingshade = j;
 		}
 	}