Added a variable to hold the rest of the list while looping.