Remove unnecessary dynamic_cast