custom group name is already part of $field, so you don't need to fetch it from db.