Fix bad cast