I think I now see what you are thinking here. That's great and obviously it works, but you might have overthought it a bit. On my machine I was able to comment out these lines (37-41) and sum_series() still worked like a charm.