# Breaking an inner loop with temporal criteria breaks also outer loop

**URL:** <https://discourse.psychopy.org/t/breaking-an-inner-loop-with-temporal-criteria-breaks-also-outer-loop/12278>\
**Category:** Online experiments\
**Created:** [April 10, 2020, 3:09pm UTC](https://discourse.psychopy.org/t/breaking-an-inner-loop-with-temporal-criteria-breaks-also-outer-loop/12278 "2020-04-10T15:09:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giulia\_Cristoforetti](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Giulia\_Cristoforetti](https://discourse.psychopy.org/u/Giulia_Cristoforetti)\
**Post date:** [April 10, 2020, 3:09pm UTC](https://discourse.psychopy.org/t/breaking-an-inner-loop-with-temporal-criteria-breaks-also-outer-loop/12278/1 "2020-04-10T15:09:53Z")

</div>

URL of experiment: [https://gitlab.pavlovia.org/Giulia/ltm\_categorization](https://gitlab.pavlovia.org/Giulia/ltm_categorization)

Description of the problem:  
Hi, my experiment has nested loops. I have an inner loop that breaks after 30 seconds. Using the code trials.finished = true also breaks my outer loop and its repetitions. I Have seen that this problem has been solved when the loop breaks after nRep. I wasn’t able to implement it for my issue.

This is my code where “counting” is my inner loop

In the routine before the inner loop  
Begin Routine  
totalTime = 0;  
timeLimit = 10;  
incrementalClock = new util.Clock();

in the inner loop

Begin routine  
incrementalClock.reset()

EachFrame  
if (((totalTime + incrementalClock.getTime())) \>= timeLimit)  
{  
counting.finished=true;  
continueRoutine =false;  
}

EndRoutine  
totalTime+=incrementalClock.getTime()

thank you for any suggestion!  
Giulia
