possibl, working tabulation-based version