Add check for empty document.