converted read/write functions to paging