add memoization of relations