refactor async write.