trigon -- memoization + buffering -- working