moved copying the list to the for loop