implement read and write