Fixed document reading
merged my changes