Handle document not found correctly