fixed casting errors