read write bug fix