Refactor getThumb() function