Refactor and example