Adding sum function, fixing not function