cleaned up example; small refactor