Clean up code for displaying error messages