fix flow control