Added count function to get the number of results of a query