Fixing bugs in when appending items to the html