added conditions to error message partial
refactored controllers to handle error messages