Change Document by pointer of Document
Replace Panic() by error return