fix append function