add writedata and readdata function