add read and write function