fixing errors in the appending process