fix flow control bug