fixed bug on counting files of directory that has thumbnail specified
modified queries