worked out log flushing