added image caching to improve performance