restructure by assignment, do assignment 2 using for loops