super fast with memoization