added total sum function