I tried to programm something in C but it goes to deep for me... I have studied a relevant paper "A CONTROL STRUCTURE FOR A VARIABLE NUMBER OF NESTED LOOPS, Skordalakis