Use sum function instead of handrolled