fix bug in auto flush