added report_error function