added error code handling to signed document