Fixed the memoization method.