use doc[key] for virtual functions otherwise the this pointer becomes undefined