Refactor createThumbnail