memoize with difference list