Refactored document post-loading code to its own method