fixed invalid cast