refactor to cleanup the example