fixing memoization