separate the group processing and write methods