removing duplication of isDirty logic