Added error messages for invalid data