Generalized repeatUntilEmpty to repeatUntilBlock