implement error handling.