adding ngroups

Hi Kazuhiro,

Adding the ngroups changes to develop as you requested. 

Thanks,
nathan