move document internal to its own structure