fixed casting bug in UnitLoader