implemented write and read