added error handling to validator