reworked caching, making more testable