Fix wrong place to set isdirty true