add list_affinity_groups and change error handling