Added logic for thumbnail database