fixed the dyn_cast bug that caused crash