implement the sum method