update examples, improve error handling