Move count method to query