refactor allowing dynamic document loading