Added some improvements with caching