Instead of creating a new table per sub-product, you could merge this with the code above and use additional tables rows. In this case you will have the full power of the existing implementation