Revised sum_series function