Fixed class cast issue