Need a comment here since we're referring to the old document in this if block and currentDocument is updated after this if block.