fixed bug in groupby