refactor and example redo