fixing flow control bug