fixes memoization/recursion depth for assignment3