Adding read and write functions