refactored- moved repeated error messages to variables