fixed bugs with write and read cache