Add error handling
Document error handling