Refactor to expose the writing portion