         if( MissingText(datavalue, key: datakey) ==  false){
             device.addToDataObject(datavalue.text!, key: datakey.text!)
         }
-        else{
-            //RegisterSwitch.setOn(false, animated: true)
-            alert("Error", messageInput: "Check your Encrypted Data Key and Value Fields")
-        }
-
         
         //checks to see if key or value is empty and throw error as necessary for unencrypted data
         if( MissingText(unencryptedDataValue, key: unencryptedDataKey) ==  false){
             device.addToUnencryptedDataObject(unencryptedDataValue.text!, key: unencryptedDataKey.text!)
         }
-        else{
-            //RegisterSwitch.setOn(false, animated: true)
-            alert("Error", messageInput: "Check your Unencrypted Data Key and Value Fields")
-        }
-        
         
         
         //when the user flicks the switch to green

    @IBOutlet weak var unencryptedDataKey: UITextField!
    @IBOutlet weak var unencryptedDataValue: UITextField!
    @IBOutlet weak var deviceType: UITextField!

    
    //pop up alert and display BM information
    @IBAction func bmAction(sender: UIButton) {
        alert("BM Information", messageInput: "Username: \(username) \n Password: \(passwd) \n Tenant ID: \(tenantID) \n Org ID: \(orgID)")
       
    }

    //UI selection for which device Type exist in the user's PI
    @IBAction func DeviceTypeAction() {
        //gets org information

        let alert = UIAlertController(title: titleInput, message: messageInput, preferredStyle: UIAlertControllerStyle.Alert)
        alert.addAction(UIAlertAction(title: "ok", style: UIAlertActionStyle.Default, handler: nil))
        self.presentViewController(alert, animated: true, completion: nil)
        
    }
    
    //function to check if both or none of the data value and key exist.
    func MissingText (value: UITextField, key : UITextField) -> Bool{
        if ( (key.text! == "" && value.text! == "")){
            print("here")
            return true
        }
        else{
            print("test")
            return false
        }
        
    }

    

    
