repair invalid casting