small helper function to add up list elements