 		NotificationCenter.default.addObserver(self, selector: #selector(textDidChange(_:)), name: UITextField.textDidChangeNotification, object: nameTextField)
 		
     }
+	
+	private func didSelect(_ account: Account) {
+		AppDefaults.addFolderAccountID = account.accountID
+		selectedAccount = account
+	}
 
 	func cancel() {
 		delegate?.processingDidEnd()
 	}
 	
 	func add() {
-		let account = accounts[accountPickerView.selectedRow(inComponent: 0)]
-		if let folderName = nameTextField.text {
-			account.addFolder(folderName) { result in
-				switch result {
-				case .success:
-					self.delegate?.processingDidEnd()
-				case .failure(let error):
-					self.presentError(error)
-				}
+		guard let folderName = nameTextField.text else {
+			return
+		}
+		selectedAccount.addFolder(folderName) { result in
+			switch result {
+			case .success:
+				self.delegate?.processingDidEnd()
+			case .failure(let error):
+				self.presentError(error)
 			}
 		}
 	}

	}
	
	func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
		accountLabel.text = (accounts[row] as DisplayNameProvider).nameForDisplay
		AppDefaults.addFolderAccountID = accounts[row].accountID
	}
	
}

		
		nameTextField.delegate = self
		
		if shouldDisplayPicker {
			accountPickerView.dataSource = self
			accountPickerView.delegate = self
			
			if let index = accounts.firstIndex(of: selectedAccount) {
				accountPickerView.selectRow(index, inComponent: 0, animated: false)
			}
			
