add flush to prevent stream block