fix read/write problem