memoize to learn