add write and read function