Reverted moving the error messages into a function that is called
only once