Refactor memoized functions