Functions up through Nested Loops