prepareWrite and executeWrite