Use dynamic_cast instead of class name for type checks