add memoization for pipes