added encode flag for appended data