fixed bug where cache was sometimes not used