add some error-handling code