fix bugs in append