addToList function updated