fixed small bug that the ui would not always reflect the current state in the document