caching works and results in big speedup