For every run() call, series() must be called the same exact number of times every time. It cannot be changed by an if statement between run() calls.

As a rule of thumb, put all series() calls outside of all if statements.