Fixed invalid cast