fixed read-write bug