solves references groupby problem