optimised the appendListItems function by using a tmp string