The call to ```core.add(cm)``` should be moved to the top of the for-loop, otherwise ```sequence``` will use the wrong series count.