some refactoring to cleanup the examples