New append_data() function