Was failing when cast class was null.