simpler summation with loops