return memo in reduce