updated counting quiery