Reverted and inverted removed logic protecting a class cast