Fix bad cast usage