Flowgorithm with an Outside Loop and an Inside Loop