add three state writing flag