I'm having problems getting expected results while morphing a nested repeat region and horizontal looper. Maybe someone has run into this or maybe I'm missing the target altogether. Any suggestions?

Thanks!

Expected results:
GROUP A (from recordset rsMaster)
GROUPA.Item1 GROUPA.Item2 GROUPA.Item3 GROUPA.Item4
GROUPA.Item5 GROUPA.Item6 GROUPA.Item7..etc
GROUP B (from recordset rsMaster)
GROUPB.Item1 GROUPB.Item2 GROUPB.Item3 GROUPB.Item4
GROUPB.Item5 GROUPB.Item6 GROUPB.Item7..etc
GROUP C (from recordset rsMaster)
GROUPC.Item1 GROUPC.Item2 GROUPC.Item3 GROUPC.Item4
GROUPC.Item5 GROUPC.Item6 GROUPC.Item7..etc


Actual Results
GROUP A (all items from all groups display under GROUP A)
Item1 Item2 Item3 Item4
Item5 Item6 Item7..etc
GROUP B
no results
GROUP C
no results
GROUP D
no results
GROUP E
no results
etc.


Code:
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsMaster_numRows = rsMaster_numRows + Repeat1__numRows
%>
<%
Dim HLooper1__numRows
HLooper1__numRows = -4
Dim HLooper1__index
HLooper1__index = 0
rsSlave_numRows = rsSlave_numRows + HLooper1__numRows
%>
<html>
<body>
 <% 
While ((Repeat1__numRows <> 0) AND (NOT rsMaster.EOF)) 
%>
<table>
<tr>
<td><%=(rsMaster.Fields.Item("TPD").Value)%></td>
</tr>
<tr>
<td>
<%
FilterParam = (rsMaster.Fields.Item("TPD").Value)
rsSlave.Filter = "TPD =  " & FilterParam
While (NOT rsSlave.EOF)
%>
<table>
<%
startrw = 0
endrw = HLooper1__index
numberColumns = 4
numrows = -1
while((numrows <> 0) AND (Not rsSlave.EOF))
	startrw = endrw + 1
	endrw = endrw + numberColumns
 %>
<tr>
<%
While ((startrw <= endrw) AND (Not rsSlave.EOF))
%>
<td>
<table>
<tr>
<td>
<img src="<%=(rsSlave.Fields.Item("Thumb").Value)%>"><br>
<%=(rsSlave.Fields.Item("ItemNo").Value)%>
</td>
</tr>
</table></td>
<%
	startrw = startrw + 1
	rsSlave.MoveNext()
	Wend
	%>
</tr>
<%
 numrows=numrows-1
 Wend
 %>
</table>
<%
rsSlave.MoveNext()
Wend
%>

</td>
</tr>
</table>
<% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsMaster.MoveNext()
Wend
%>
</body>
</html>