Fixed groupby and output directory