bad cast fixed