implemented read and write