added for loops, to be debugged