updated read and write logic