generalize previous fix to N streams