added a rudimentary caching implementation