added exception handling
refactored all examples