modify loadDoc function.