solution for flow control exercise 3