created summation function