add read and write func