substitute reduce with fold