added memoization (.net)