fix to append buffer logic