add write and read functions