Several of my online demos do this (Independent Randomisation, PM N-Back, PM Time and Trial Switching)
However, your solution could be even simpler, if you have one block and then a routine that ends if trials.thisN%25 > 0 and can change the parameters for the following trials.