refactored analysis_group. cleaned up processing