fix invalid cast