Add memoization to the position method.