properly redirect and display error messages when errors exist