simplify read() and write()