playing with arrays
refactoring sum method