implementing sum using foldLeft