Rewrote memoized to be a two-in-one.