more uses of forEach; improved the error messages