moved list++ to end of loop