memoization closes #8