Refactor and make example