Fix #11: Invalid downcast check