added code examples for error handling