fixed a bottleneck due to bad caching