added flushing to accommodate logging