Fixed problem with using memoized in global function