Changed total calculation to use fold instead of reduce (to allow for
empty lists)