fold and reduce