Added memoize library function