code edited for thumbnails