Fixed class cast problem