fixing bug when appending the list