fix end list, add sum function