fix read and write state