refactor error aggregation into separate method