added query for counting resutls