simplified memoization technique