Remove duplication of function addToList