add sum and foreach