experiment with caching the state string (functools.lru_cache)