> I'm not sure there's a better way to do it.

wrt docs, type, or what ?