better isDirty function