you are right. This looks suspicious. This really MAY cause the class cast exception you are seeing. But I’m not sure. You could try to debug what exactly is happening there. But IMHO this code looks really wrong.
Do you play Magic?
Get TopDecked MTG, the #1 Magic App, built by players, for players. Free to use, forever.