     func saveDeck(update: Bool) {
         guard let deck = deck, let cards = cards, cards.isValidDeck() else { return }
 		
-		RealmHelper.update(deck: deck, with: cards)
-        RealmHelper.add(deck: deck, update: update)
+		if update {
+			RealmHelper.update(deck: deck, with: cards)
+		} else {
+			RealmHelper.add(deck: deck, with: cards)
+		}
         
         NotificationCenter.default.post(name: Notification.Name(rawValue: "reload_decks"),
                                         object: deck)

    @IBAction func save(_ sender: AnyObject) {
        guard let deck = deck, let cards = cards, cards.isValidDeck() else { return }

        RealmHelper.rename(deck: deck, to: deckName.stringValue)
        self.saveDeck(update: exists)
    }



        deckName.stringValue = deck!.name 

        if let deck = RealmHelper.getDeck(with: deck!.deckId) {
			self.deck = deck
			exists = true
        } else {
            Log.error?.message("Can not fetch deck")
        }
