Added error handling for item validation.