Very neat solution!
If I may add my 2 cents, using ID is fine as long as the repeating group isn’t nested in another one because this would generate multiple RG with same ID which is not supposed…
Using Classify plugin, it’s possible to set CSS classes instead. The code would become: