diff --git a/src/uncategorized/placeInLine.tw b/src/uncategorized/placeInLine.tw
index 30ac0fdf046b140a3945b03cfdc0216487c6860c..99c31edbc4577d688ba47005421d4eb716166891 100644
--- a/src/uncategorized/placeInLine.tw
+++ b/src/uncategorized/placeInLine.tw
@@ -9,7 +9,8 @@
 <<if ($activeSlave.assignmentVisible == 1)>>
 	<<for _pil = _activeSlaveIndex - 1; _pil != _activeSlaveIndex; _pil-->> /* loops backwards through the $slaves array */
 		<<if _pil < 0>>
-			<<set _pil = _SL - 1>>
+			<<set _pil = _SL>>
+			<<continue>>
 		<</if>>
 		<<if $slaves[_pil].assignmentVisible == 1>>
 			<<set $slavesInLine.push(_pil)>> /* index of the previous slave in line */
@@ -18,7 +19,8 @@
 	<</for>>
 	<<for _pil = _activeSlaveIndex + 1; _pil != _activeSlaveIndex; _pil++>> /* this loops forwards through the $slaves array */
 		<<if _pil == _SL>>
-			<<set _pil = 0>>
+			<<set _pil = -1>>
+			<<continue>>
 		<</if>>
 		<<if $slaves[_pil].assignmentVisible == 1>>
 			<<set $slavesInLine.push(_pil)>> /* index of the next slave in line */
@@ -28,7 +30,8 @@
 <<else>>
 	<<for _pil = _activeSlaveIndex - 1; _pil != _activeSlaveIndex; _pil-->> /* loops backwards through the $slaves array */
 		<<if _pil < 0>>
-			<<set _pil = _SL - 1>>
+			<<set _pil = _SL>>
+			<<continue>>
 		<</if>>
 		<<if ($slaves[_pil].assignment == $activeSlave.assignment)>>
 			<<set $slavesInLine.push(_pil)>> /* index of the previous slave in line */
@@ -37,7 +40,8 @@
 	<</for>>
 	<<for _pil = _activeSlaveIndex + 1; _pil != _activeSlaveIndex; _pil++>> /* this loops forwards through the $slaves array */
 		<<if _pil == _SL>>
-			<<set _pil = 0>>
+			<<set _pil = -1>>
+			<<continue>>
 		<</if>>
 		<<if ($slaves[_pil].assignment == $activeSlave.assignment)>>
 			<<set $slavesInLine.push(_pil)>> /* index of the next slave in line */