completed append function