fixed a class cast bug