update writeList() function