smarter table lookup