factored out addToList function