fix the memoize function to hash of unique key