Handle document modified better