fixing sum function