added version which has a sum function