fixes for the read/write logic