attempting to fix segault that happends in cast.