reworked dynamic for loops