added the possibility to end measurements after a given number of sets