fix bug where app crashed after reloading document