refactored createCachedThumbnail