improved members query to aggregate data