When you have done your thing a certain number of times make a variable true.
When your variable is true make a decision to stop doing the first thing then start doing the next thing.
Eat some food, eat some more eat some more.
Are you full?
Rest some, rest some more, rest some more . . . . .