@rsquared1 From what I see this should work, you could try separating this code and placing a modify variables block in between custom code blocks to solely reset the variable, or maybe just separating will ensure one task is finished before starting the next.