add r-error-handling