fixed error handling in examples
cleaned up exampel