Adding the iteration code