Refining code where new document uses last selected process if available