cast to correct type