memoization helpers