fix a bug in Flush()