implement group_names function