Added fold and sum functions