fix logic bug in thumbnail selection