sum method made recursive