Added appendError function