implements some pretty naive caching