add output flushing