Refactor writer