Fixed small mistake in memoization