calculate sums