Got a document update function that doesnt break. Still needs more for loops and if statemenets