fixed (and tested) sum function