Modified the read/write functions