add parsing function with memoization