fix to make lr memoization linear