fixed invalid cast exception