completed the draft implementation for flush_writes