Outer Loop and Inner Loop in Flowgorithm