Refactor for SelectWriter::write()