 			return nil
 		}
 		
-		return realm.objects(Deck.self).filter("deckId = '\(id)'").first
+		if let deck = realm.objects(Deck.self).filter("deckId = '\(id)'").first {
+			RealmHelper.validateCardCounts(deck)
+			return deck
+		}
+		return nil
+	}
+	
+	static func validateCardCounts(_ deck: Deck) {
+		guard let realm = try? Realm() else {
+			Log.error?.message("Error accessing Realm database")
+			return
+		}
+		
+		do {
+			try realm.write {
+				for card in deck.cards {
+					if card.count > 30 {
+						card.count = 1
+					}
+				}
+			}
+		} catch {
+			Log.error?.message("Can't update deck")
+		}
 	}
 	
 	static func set(hsDeckId: Int64, for deckId: String) {

            Log.error?.message("Error accessing Realm database")
            return nil
        }
        
        return Array(realm.objects(Deck.self))
    }
	
	static func getActiveDecks() -> [CardClass: [Deck]]? {

		Realm.Configuration.defaultConfiguration = config
	}
	
	// MARK: - Deck operations
	
	static func getDeck(with id: String) -> Deck? {
