memoization speced and impmtd