reorganized functions into the order that the flowchart shows them. The calls and returns were already listed in order.