I'm writing batch class to count number of Contacts associated with Account, I want to update custom field in Account object Number\_of\_Contacts, this field counts the number of contacts associated with each Account. I'm shearing my code ... 

```
global class CountNumberOfContacts implements Database.Batchable<SObject> {

global Database.QueryLocator start(Database.BatchableContext bc)
{
    return Database.getQueryLocator([Select id from Account]);
}

global void execute(Database.BatchableContext bc, List<Account> scope )
{   List <Account> UpAcc = new List<Account>(); 
    List <AggregateResult> acclist = [Select AccountId, count(id) from contact where AccountId in : scope group by AccountId];
    system.debug ('>>>>> AggregateResult >>>>>' + acclist);
    if(!acclist.isEmpty())
    {

        //I'm stuck here... acclist is empty
    }
}

global void finish(Database.BatchableContext bc)
{

}
}

```