Update example with error logging. Improve comment