added error_code and fixed missing close bracket