possibly the only legit use of dynamic_cast I've ever done.