replace dynamic_cast with static_cast