optimization: avoid frequent flushing