You probably just need to move the subcategories recordset from lines 9-13 inside of the repeat region after line 27.
That will cause the subcategories to be re-populated with each new category.
You should be able to use a standard repeat region for both of these as well. Since they are different recordsets, they should be able to be nested. The improved repeat region is only necessary for nested repeats of the same recordset, and if you want a fixed number of rows displayed regardless of the recordset results (or even without a recordset).